/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.actions.tipo;

import com.mapping.TipoDisp;
import com.opensymphony.xwork2.ActionSupport;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Ricardo
 */
@Namespace(value = "/")
@Action(value = "gestionModificarTipoPre", results = {
    @Result(name = "success", location = "/GestionTipos/gestionModificarTipo.jsp")})
public class ModificarTipoPre extends ActionSupport {

    private int idTipo;
    private TipoDisp tipo;

    @Override
    public String execute() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();
        tipo = (TipoDisp) em.getReference(TipoDisp.class, idTipo);
        em.flush();
        tx.commit();
        em.close();
        return SUCCESS;
    }

    public TipoDisp getTipo() {
        return tipo;
    }

    public void setIdTipo(int idTipo) {
        this.idTipo = idTipo;
    }
}
